package com.cadre.web.controller.officer;

import com.cadre.common.utils.R;
import com.cadre.common.utils.common.GenerateUUID;
import com.cadre.common.utils.oldutil.ValidatorUtils;
import com.cadre.system.domain.officer.A12;
import com.cadre.system.service.A12Service;
import com.cadre.system.service.DIC_ZBService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(value = "退出信息Controller", tags = {"退出信息接口"})
@RequestMapping({"/profess/a12"})
@RestController
/* loaded from: A12Controller.class */
public class A12Controller {
    @Autowired
    private A12Service a12Service;
    @Resource
    private DIC_ZBService dIC_ZBService;

    @PostMapping({"/editA12Msg"})
    @ApiOperation("操作退出信息")
    public R editA12Msg(@RequestBody A12 a12) {
        if (!(a12.getPersonid() == null || a12.getPersonid() == "")) {
            this.a12Service.deleteByPersonId(a12.getPersonid());
        }
        if (a12.getStatus().equals("2")) {
            a12.setFlowid(GenerateUUID.getUUID());
            this.a12Service.getBaseMapper().insert(a12);
        }
        return R.ok();
    }

    @GetMapping({"/info/{personId}"})
    @ApiOperation("根据人员ID获取退出信息")
    public R list(@PathVariable String personId) {
        List<A12> list = this.a12Service.selectList(personId);
        A12 a12 = new A12();
        if (list.size() > 0) {
            a12 = list.get(0);
        }
        return R.ok().put("a12", (Object) a12);
    }

    @PostMapping({"/save"})
    @ApiOperation("添加退出信息")
    public R save(@RequestBody A12 a12) {
        a12.setFlowid(GenerateUUID.getUUID());
        this.a12Service.getBaseMapper().insert(a12);
        return R.ok();
    }

    @PostMapping({"/update"})
    @ApiOperation("退出信息修改")
    public R update(@RequestBody A12 a12) {
        ValidatorUtils.validateEntity(a12, new Class[0]);
        a12.setSerial(((A12) this.a12Service.getBaseMapper().selectById(a12.getFlowid())).getSerial());
        this.a12Service.getBaseMapper().updateById(a12);
        return R.ok();
    }

    @PostMapping({"/delete"})
    @ApiOperation("删除退出信息")
    public R delete(@RequestBody String[] personids) {
        this.a12Service.getBaseMapper().deleteBatchIds(Arrays.asList(personids));
        return R.ok();
    }

    @GetMapping({"/getA1201"})
    @ApiOperation("退出方式字典")
    public R getA1201() {
        Map<String, Object> map = new HashMap<>();
        map.put("tableName", "dic_zb1010");
        return R.ok().put("data", (Object) this.dIC_ZBService.getAll(map));
    }
}
